print('--------------模拟购物车---------------')

goods = [];
while True :
    no = input('请输出商品编号，商品名称')
    goods.append(no)
    if input('继续添加？y/n').lower() == 'y' :
        continue
    else :
        for item in range(len(goods) - 1, -1, -1):
            print(goods[item])
        break

print('-----------添加购物车----------------')
car = []
while True :
    id = input('输入商品编号')
    for row in goods :
        if row.find(id)  > -1 :
            car.append(row)
            break
    if input('继续添加？y/n').lower() == 'y' :
        continue
    else:
        break

print('购物车的商品：')
for item in range(len(car)-1,-1,-1) :
    print(car[item])
